//
//  MqBrandShopTableViewCell.m
//  Meiqi
//
//  Created by lanou on 16/1/14.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqBrandShopTableViewCell.h"

@implementation MqBrandShopTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addSubviews];
        
    }
    return self;
}

- (void)addSubviews
{
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, kScreenWidth - 60, 30)];
    //_nameLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_nameLabel];
    
    _starsLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 45, 100, 20)];
    for (int i = 0; i < 5; i ++) {
        UIImageView *starImage = [[UIImageView alloc] initWithFrame:CGRectMake(0 + 20 * i, 0, 20, 20)];
        starImage.image = [UIImage imageNamed:@"icon_shop_detail_noRate@3x"];
        starImage.tag = 50 + i;
        [_starsLabel addSubview:starImage];
    }
    [self.contentView addSubview:_starsLabel];
    
    _rating_timesLabel = [[UILabel alloc] initWithFrame:CGRectMake(110, 45, kScreenWidth - 120, 20)];
    //_rating_timesLabel.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:_rating_timesLabel];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, kScreenWidth - 20, 1)];
    //label.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:label];
    
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 75, 30, 30)];
    imageV.image = [UIImage imageNamed:@"icon_shop_redlocation@2x"];
    [self.contentView addSubview:imageV];
    
    _addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 75, kScreenWidth - 90, 30)];
    //_addressLabel.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:_addressLabel];
    
    _contactButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _contactButton.frame = CGRectMake(kScreenWidth - 40, 75, 30, 30);
    [_contactButton setImage:[UIImage imageNamed:@"icon_shop_redphone@3x"] forState:(UIControlStateNormal)];
    //_contactButton.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_contactButton];
    
    
    
}

- (void)setModel:(MqBrandDetailShopsModel *)model
{
    _model = model;
    
    NSInteger num = [model.stars integerValue];
    for (int i = 0; i < num; i ++) {
        UIImageView *star = [_starsLabel viewWithTag:50 + i];
        star.image = [UIImage imageNamed:@"icon_shop_detail_rate@3x"];
    }
    
    
    
    _nameLabel.text = model.name;
    _rating_timesLabel.text = [NSString stringWithFormat:@"%@评论",model.rating_times];
    _addressLabel.text = model.address;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
